/**
*┌──────────────────────────────────────────────────────────────┐
*│　描    述：User_amount_log                                                    
*│　作    者：NetCoreCMS                                            
*│　版    本：1.0    模板代码自动生成                                                
*│　创建时间：2019-12-25 10:52:46                             
*└──────────────────────────────────────────────────────────────┘
*┌──────────────────────────────────────────────────────────────┐
*│　命名空间： NetCoreCMS.Services                                  
*│　类    名： User_amount_logService                                    
*└──────────────────────────────────────────────────────────────┘
*/
using NetCoreCMS.IRepository;
using NetCoreCMS.IServices;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace NetCoreCMS.Services
{
    public class User_amount_logService: IUser_amount_logService
    {
        private readonly IUser_amount_logRepository _repository;

        public User_amount_logService(IUser_amount_logRepository repository)
        {
            _repository = repository;
        }

        public int Add(int user_id, string user_name, decimal value, string remark)
        {
            Models.User_amount_log model = new Models.User_amount_log();
            model.user_id = user_id;
            model.user_name = user_name;
            model.value = value;
            model.remark = remark;
            return _repository.Add(model);
        }
        public int Add(int user_id, string user_name, decimal value, string remark,int leixing)
        {
            Models.User_amount_log model = new Models.User_amount_log();
            model.user_id = user_id;
            model.user_name = user_name;
            model.value = value;
            if (leixing == 1)
                model.remark = remark + ",奖金支付";
            if (leixing == 2)
                model.remark = remark + ",重消支付";
            return _repository.Add(model,leixing);
        }

        public bool Delete(int id, string user_name)
        {
            return _repository.DeleteList("where id=@id and user_name=@user_name", new { id=id,user_name=user_name}) > 0;
        }

        public List<Models.User_amount_log> GetList(int pageNumber, int rowsPerPage, string conditions, string orderby, object parameters = null)
        {
            return _repository.GetListPaged(pageNumber, rowsPerPage, conditions, orderby, parameters).ToList();
        }
        public int RecordCount(string conditions, object parameters = null)
        {
            return _repository.RecordCount(conditions, parameters);
        }
    }
}